
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region PhoneServe Model -(by fangyifeng at 2007-09-14 12:24:15)

	/// <summary>
	/// PhoneServe object'PhoneServe'.
	/// </summary>
	[Serializable]
	public class PhoneServe : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected string _name;
		protected string _phone;
		protected DateTime _onDate;
		protected short _isReply;
		protected SystemUser _systemUser;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public PhoneServe() { }

		public PhoneServe( string name, string phone, DateTime onDate, short isReply, SystemUser systemUser )
		{
			this._name = name;
			this._phone = phone;
			this._onDate = onDate;
			this._isReply = isReply;
			this._systemUser = systemUser;
		}

		#endregion

		#region Public Properties

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual string Name
		{
			get { return _name; }
			set
			{
				if ( value != null && value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
				_name = value;
			}
		}

		public virtual string Phone
		{
			get { return _phone; }
			set
			{
				if ( value != null && value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Phone", value, value.ToString());
				_phone = value;
			}
		}

		public virtual DateTime OnDate
		{
			get { return _onDate; }
			set { _onDate = value; }
		}

		public virtual short IsReply
		{
			get { return _isReply; }
			set { _isReply = value; }
		}

		public virtual SystemUser SystemUser
		{
			get { return _systemUser; }
			set { _systemUser = value; }
		}

		
        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is PhoneServe))
				throw new InvalidCastException("This object is not of type PhoneServe");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((PhoneServe)obj).Id);
					break;
				case "Name":
					relativeValue = this.Name.CompareTo(((PhoneServe)obj).Name);
					break;
				case "Phone":
					relativeValue = this.Phone.CompareTo(((PhoneServe)obj).Phone);
					break;
				case "OnDate":
					relativeValue = this.OnDate.CompareTo(((PhoneServe)obj).OnDate);
					break;
				case "IsReply":
					relativeValue = this.IsReply.CompareTo(((PhoneServe)obj).IsReply);
					break;
                default:
                    goto case "Id";
			}
            if (PhoneServe.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
